import request from "@/utils/request";

const ${ClassName?upper_case}_BASE_URL = "/wz/${moduleName}/${functionName}";

class ${ClassName}API {
/** 获取${tableComment}分页数据 */
static getPage(queryParams?: ${ClassName}PageQuery) {
return request<any, PageResult<${ClassName}PageVO[]>>({
            url: `<#noparse>${</#noparse>${ClassName?upper_case}_BASE_URL}/page`,
            method: "get",
            params: queryParams,
        });
    }

    /**
* 获取${tableComment}表单数据
     *
* @param id ${ClassName}ID
* @returns ${ClassName}表单数据
     */
    static getFormData(id: number) {
return request
<any, ${ClassName}Form>({
            url: `<#noparse>${</#noparse>${ClassName?upper_case}_BASE_URL}/detail?id=`+id,
            method: "get",
        });
    }

/** 添加${tableComment}*/
static add(data: ${ClassName}Form) {
        return request({
url: `<#noparse>${</#noparse>${ClassName?upper_case}_BASE_URL}/save`,
            method: "post",
            data: data,
        });
    }

    /**
* 更新${tableComment}
     *
* @param id ${ClassName}ID
* @param data ${ClassName}表单数据
     */
static update(data: ${ClassName}Form) {
        return request({
url: `<#noparse>${</#noparse>${ClassName?upper_case}_BASE_URL}/update`,
            method: "put",
            data: data,
        });
    }

    /**
* 批量删除${tableComment}，多个以英文逗号(,)分割
     *
* @param ids ${tableComment}ID字符串，多个以英文逗号(,)分割
     */
    static deleteByIds(ids: string) {
        return request({
url: `<#noparse>${</#noparse>${ClassName?upper_case}_BASE_URL}/remove?ids=`+ids,
            method: "delete",
        });
    }
}

export default ${ClassName}API;

/** ${tableComment}分页查询参数 */
export interface ${ClassName}PageQuery extends PageQuery {
<#list queryList as field>
    <#if field.fieldComment!?length gt 0>
        /** ${field.fieldComment} */
    </#if>
    <#if field.attrType == 'Long' || field.attrType == 'Integer'>
        ${field.attrName}?: number;
    <#elseif field.attrType == 'String'>
        ${field.attrName}?: string;
    <#elseif field.attrType == 'LocalDateTime'>
        ${field.attrName}?: string;
    <#else >
        ${field.attrName}?: string;
    </#if>
</#list>
}

/** ${tableComment}表单对象 */
export interface ${ClassName}Form {
<#list formList as field>
    <#if field.fieldComment!?length gt 0>
        /** ${field.fieldComment} */
    </#if>
    <#if field.attrType == 'Long' || field.attrType == 'Integer'>
        ${field.attrName}?: number;
    <#elseif field.attrType == 'String'>
        ${field.attrName}?: string;
    <#elseif field.attrType == 'LocalDateTime'>
        ${field.attrName}?: string;
    <#else >
        ${field.attrName}?: string;
    </#if>
</#list>
}

/** ${tableComment}分页对象 */
export interface ${ClassName}PageVO {
<#list gridList as field>
    <#if field.fieldComment!?length gt 0>
        /** ${field.fieldComment} */
    </#if>
    <#if field.attrType == 'Long' || field.attrType == 'Integer'>
        ${field.attrName}?: number;
    <#elseif field.attrType == 'String'>
        ${field.attrName}?: string;
    <#elseif field.attrType == 'LocalDateTime'>
        ${field.attrName}?: string;
    <#else >
        ${field.attrName}?: string;
    </#if>
</#list>
}
